import store from '@/store/index.js'

const multiClient = [{
  clientCode: "EBIKE_ADMIN",
  loginPath: "/ebike/login"
},{
  clientCode: "EBIKE_BMS",
  loginPath: "/bms/login"
},{
  clientCode: "CABINET_ADMIN",
  loginPath: "/cabinet/login"
}]

/**
 * 获取登录白名单
 * @returns 
 */
export function getLoginwhiteList() {
  return multiClient.map(item => item.loginPath);
}

/**
 * 获取登录路径
 * @param {string} clientCode 
 * @returns 
 */
export function getLoginPath() {
  const clientCode = store.state.user.clientCode;
  const client = multiClient.find(item => item.clientCode === clientCode);
  if(client){
    return client.loginPath;
  }else{
    return "/user/login";
  }
}

export function setClientCode(clientCode){
  store.commit('user/SET_CLIENT_CODE', clientCode);
}
